<?php

class SiteController extends BackEndController {
    public function filters() {
        return array(
            'accessControl', // perform access control for CRUD operations
        );
    }

    public function  actionLogin() {
        $this->redirect(HSUrl::backendLoginUrl());
    }

    public function accessRules() {
        return array(
            array(
                'allow',
                'actions' => array('login', 'logout'),
                'users' => array('*'),
            ),
            array(
                'allow',
                'actions' => array(
                    'index', 'view', 'create', 'update', 'admin', 'delete', 'task'
                ),
                'users' => array('@'),
            ),
            array('deny', // deny all users
                'users' => array('*'),
            ),
        );
    }

    public function actionIndex() {
        $this->layoutPageTitle = 'Trang chính';

        $this->render('index');

    }

    public function actionError() {
        if ($error = Yii::app()->errorHandler->error) {
            if (Yii::app()->request->isAjaxRequest)
                echo $error['message'];
            else
                $this->render('index', $error);
        }
    }

}